from app.libs.redprint import Redprint
from app.models.banner import Banner
from flask import jsonify

from app.models.base import db
from app.models.taobao_orders import taobao_orders
from app.validators.tb_orders import ReceiveOrdersForm

api = Redprint('tb_orders')


@api.route("/receive", methods=['POST'])
def receive():
    form = ReceiveOrdersForm().validate_for_api()
    with db.auto_commit():
        taobao_order_model = taobao_orders()
        taobao_order_model.order_number = form.order_number.data
        taobao_order_model.amount = form.amount.data
        taobao_order_model.total = form.total.data
        taobao_order_model.title = form.title.data
        taobao_order_model.order_detail = form.order_number.data
        db.session.add(taobao_order_model)
    return jsonify()


